#include "Param.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Param_classType = NULL;
VTable* Param_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Str toStr() */
Str* Param_toStr(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Param.toStr not implemented yet"));
}


/* Str name() */
Str* Param_name(Param* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Param.name not implemented yet"));
}


/* Type type() */
Type* Param_type(Param* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Param.type not implemented yet"));
}


/* Bool hasDefault() */
Bool Param_hasDefault(Param* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Param.hasDefault not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Param_initType(void)
{
  if (Param_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Param_initVTable();
    Type* type = Type_new("Param", baseType, vtable, sizeof(Param), sizeof(ParamVTable));
    Type_registerMethodImplementation(type, "hasDefault", Param_hasDefault, 0);
    Type_registerMethodImplementation(type, "name", Param_name, 0);
    Type_registerMethodImplementation(type, "toStr", Param_toStr, 0);
    Type_registerMethodImplementation(type, "type", Param_type, 0);
    Param_classType = type;
    Param_initStatic();
  }
  return Param_classType;
}


VTable* Param_initVTable(void)
{
  if (Param_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(ParamVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((FanObjVTable*)vtable)->toStr = Param_toStr;
    Param_classVTable = vtable;
  }
  return Param_classVTable;
}


void Param_initStatic(void)
{
}
